home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
batchut
/
xset402.zip
/
DEMO.BAT
< prev
next >
Wrap
DOS Batch File
|
1994-03-29
|
13KB
|
338 lines
@echo off
if "%1" == "second_time" goto begin
if exist XSET.EXE goto OK_to_go
echo You must be in the directory containing XSET
exit
goto end
:OK_to_go
:: ┌───────────────────────────────────────────────────────────────────────┐
:: │ Run a new shell with environment big enough (10,000 bytes to be sure) │
:: └───────────────────────────────────────────────────────────────────────┘
:: run a new command.com with more environment space
if "%comspec%" == "" command/e:10000/c demo.bat second_time
if not "%comspec%" == "" %comspec%/e:10000/c demo.bat second_time
goto end
:begin
cls
echo ╔═════════════════════════════════════════════════╗
echo ║ ║
echo ║ ░░░▒▒▒▓▓▓ Welcome to XSET demo ▓▓▓▒▒▒░░░ ║
echo ║ ║
echo ╚═════════════════════════════════════════════════╝
echo:
echo Hello,
echo:
echo:
echo Although you always thought you cannot perform real programming with DOS
echo batch files, this demo will show you it is feasible; furthermore, it will
echo show you it is very easy to do.
echo:
echo What really lacks in DOS is a way to handle environment variables.
echo The only thing DOS allows you to do is to assign a variable to a value
echo and to use its value.
echo:
echo Did you ever dream to get a user's answer into an environment variable,
echo or the result of a calculation, or the output of a program ?
echo Did you ever try to find a way to write a batch file that will allow
echo a selective behaviour for different configurations (like different
echo processor types or day of the week,...) ?
echo:
pause
cls
echo So, why do YOU need XSET ?
echo:
echo 1. Because you are PC support (like me) and often have to write batch files
echo that will be used by a great number of people and they must be very
echo context-dependant and highly interactive (especially if users do not know
echo about DOS and they panic if they see 'Abort, Retry, Fail?').
echo:
echo 2. Because you need to work in different environments ( for example you are
echo are connected to different networks, or you swap between two development
echo environment - compilers,... ) and you have to maintain two sets of batch
echo files.
echo:
echo 3. Because you do not like to see your batch files waiting for you the whole
echo night because you forgot to insert a floppy into drive A: and locking the
echo computer instead of running your communication software.
echo:
echo 4. Because you simply want to interactively edit your path ( or any other
echo variable), save all your environment to restore it later,...
echo In other words, you want to have full control of your environment.
echo:
echo:
pause
cls
echo The main goal of XSET is to put ANYTHING YOU WANT into an environment variable
echo and to modify it LIKE YOU WANT; it also by-passes the internal limits of plain
echo DOS like the 128 characters limit (very useful if you need a very long path).
echo But XSET also provide a lot of built-in facilities like full floating-point
echo calculation, time and date handling, system information (kind of CPU, is a
echo disk ready,...), customized prompts (also in color) and much more !!!
echo:
echo XSET is fully compatible with MS-DOS, DR-DOS, 4DOS, NDOS, Windows & OS/2.
echo:
echo XSET is not only the most powerful environment variables manipulation program
echo you ever saw, but it also has a very easy and intuitive user interface (very
echo close to the DOS 'SET' command).
echo:
echo Example 1: to ask the user's name and store the result in a variable 'name'
echo XSET /PROMPT "Enter your name: " name
echo:
echo Example 2: to store the processor type in a variable 'cpu_kind'
echo XSET cpu_kind CPU
echo:
echo Example 3: to extract the 5 firsts characters of a string
echo XSET /LEFT 5 var="any string you want even with another variable %var%"
echo:
echo Type any key to get XSET help on-line...
pause > nul
xset
cls
echo Following is a demo which only goal is to show how powerful XSET is.
echo The demo itself is not very useful but it implements a kind of very
echo limited file manager.
echo None of the messages, colors, default values or behaviours are
echo hard-coded into the program; they all are given as parameters in
echo the batch file.
echo XSET is not limited to this kind of handling; I only had to choose
echo something that has a great level of interaction because it is better
echo for a demo but the most powerful features of XSET are generally used
echo for non- interactive procedures.
echo:
echo Note for people who have a monochrome monitor and a color video
echo board: The demo displays messages in color but you normally should
echo read everything correctly (you even will see highlight).
echo:
echo:
echo Because of the way the information are displayed on the screen, the
echo drawing may be very slow ( especially if you do not have a disk
echo cache installed). This is because the XSET program is called a lot
echo of times for the menu display (only to have fancy colors).
echo:
echo:
pause
cls
echo First of all, some system checks.
echo Note that all displayed results are actually stored into an environment
echo variable; the following message are using the normal DOS 'echo' command.
echo:
echo:
XSET _xtmp CPU
if "%CPU%" == "86" set _xtmp=086
echo CPU kind: 80%_xtmp%
:: the following trick would be useless if the 'FOR' command
:: would allow to perform several actions in a loop
:: (so we create and call a batch file)
echo XSET _xtmp DRIVETEST %%1 > _xtmp.bat
echo echo drive %%1: status: %%_xtmp%% >> _xtmp.bat
for %%d in (A B C X) do call _xtmp.bat %%d
del _xtmp.bat
XSET _xtmp TIME
echo Current time: %_xtmp%
XSET _xtmp DIR c:
echo current dir of drive C: \%_xtmp%
XSET _xtmp VOLLABEL c:
echo volume label of drive C: %_xtmp%
XSET _xtmp BYTEFREE c:
echo bytes free on drive C: %_xtmp%
XSET _xtmp FDATE c:\autoexec.bat
echo c:\autoexec.bat - date: %_xtmp%
XSET _xtmp FSIZE c:\autoexec.bat
echo c:\autoexec.bat - size: %_xtmp%
echo:
echo:
pause
:: -----------------------------------------------------
:demo
:: ┌─────────────────────────────────────────┐
:: │Get current drive & path into environment│
:: └─────────────────────────────────────────┘
XSET _xdrive FDRIVE *
XSET/MID 3 100 _xdir FDIR *
:: ┌──────────────────────────────────────────────┐
:: │ Store current path & add this directory to it│
:: └──────────────────────────────────────────────┘
XSET _xpath VARCOPY path
set path=%_xdrive%%_xdir%;
XSET/APPEND path varcopy _xpath
:: ┌──────────────────┐
:: │Set default values│
:: └──────────────────┘
set _xfile=*.*
set _xoptions=/P
XSET _xdate DATE
set _xpos=3
:: ┌─── Show menu on Screen ──────────────────────────────────────────────┐
:: │ │
:: ├─── This is purely examplative ───────────────────────────